home *** CD-ROM | disk | FTP | other *** search
- * Function: Display fileone and filetwo in separate windows and locate the
- * next and previous deletion or insertion.
- * To run: While editing the second of two files you wish to compare
- * (filetwo), execute the macro VCS with a fileone parameter (where
- * fileone is the first of two files you wish to compare). VCS will
- * save fileone and filetwo if necessary, run Visual Compare (using
- * the /D command line option and with the difference file redirected
- * to the file VCS.TMP), load VCS.TMP, and locate the first deletion
- * or insertion. To locate the next deletion or insertion, press the
- * Alt-N key or the key defined by the EDITV variable "vc_next_key."
- * To locate the previous deletion or insertion, press the ALT-P key
- * or the key defined by the EDITV variable "vc_prev_key." To toggle
- * between vertical and horizontal windows, press the F9 key or the
- * key defined by the EDITV variable "vc_split_key." You can also
- * execute the macro VCS with both fileone and filetwo parameters.
- * To execute the macro VCS from the DOS command line, see VCS.BAT.
- * Requires: KEDIT 4.0
- * User set EDITV variables:
- * vcs_next_key default: "Alt-N" locate next deletion or insertion
- * vcs_prev_key default: "Alt-P" locate previous deletion or insertion
- * vcs_split_key default: "F9" toggle between vertical and horizontal
- * windows
- * Internal EDITV variables:
- * vcs_fileone
- * vcs_filetwo
- * vcs.0 number of differences
- * vcs.1...vcs.n whether each difference is deletion or insertion
- * vcs_current current difference
-
- arg = arg(1)
- IF arg = '!split' THEN
- DO
- 'extract /screen'
- IF word(screen.1, 1) = 'SIZE' & word(screen.1, 3) = 'SPLIT' THEN
- 'set screen 2'
- ELSE
- 'set screen 2 v'
- 'sos current firstcol'
- exit
- END
- 'editv get vcs.0'
- IF arg <> '!next' & arg <> '!prev' THEN
- DO
- IF word(arg, 3) = '!cline' THEN
- 'macro' defprofile.1()
- vcs_fileone = word(arg, 1)
- vcs_filetwo = word(arg, 2)
- IF vcs_filetwo = '' THEN
- vcs_filetwo = fileid.1()
- 'kedit' vcs_fileone '(nodefext'
- IF rc <> 0 THEN
- exit
- vcs_fileone = fileid.1()
- IF alt() THEN
- DO
- 'save'
- IF rc <> 0 THEN
- exit
- END
- 'kedit' vcs_filetwo '(nodefext'
- IF rc <> 0 THEN
- exit
- vcs_filetwo = fileid.1()
- IF alt() THEN
- DO
- 'save'
- IF rc <> 0 THEN
- exit
- END
- 'editv put vcs_fileone vcs_filetwo'
- IF word(arg, 3) <> '!cline' THEN
- * Write the difference file to VCS.TMP.
- 'dos vcomp' vcs_fileone vcs_filetwo '/D > VCS.TMP'
- 'kedit .:.\VCS.TMP (noprof'
- IF rc <> 0 THEN
- exit
- IF size.1() = 0 THEN
- DO
- 'quit'
- 'erase .:.\VCS.TMP'
- exit
- END
- filetmp = fileid.1()
- * Process VCS.TMP.
- vcs_current = 0
- DO FOREVER
- 'kedit' filetmp '(noprof'
- 'next'
- IF rc <> 0 THEN
- DO
- 'quit'
- 'erase .:.\VCS.TMP'
- leave
- END
- vcs_current = vcs_current + 1
- 'extract /curline'
- * Save whether this difference is a deletion or an insertion.
- vcs.vcs_current = word(curline.3, 3)
- 'editv put vcs.'vcs_current
- * Save the corresponding file positions and the end of the deletion
- * or insertion block by naming them.
- 'kedit' vcs_fileone '(nodefext'
- 'locate :'word(curline.3, 1)
- 'set point .vcs1.'vcs_current
- IF vcs.vcs_current = '1' THEN
- DO
- * Save end of deletion block.
- 'locate' word(curline.3, 4) + 1
- 'set point .vcs2.'vcs_current
- END
- 'kedit' vcs_filetwo '(nodefext'
- 'locate :'word(curline.3, 2)
- 'set point .vcs1.'vcs_current
- IF vcs.vcs_current = '2' THEN
- DO
- * Save end of insertion block.
- 'locate' word(curline.3, 4) + 1
- 'set point .vcs2.'vcs_current
- END
- END
- * Clear extra EDITV variables from last run.
- IF datatype(vcs.0, 'n') THEN
- DO i = vcs_current + 1 to vcs.0
- 'editv set vcs'.i
- END
- vcs.0 = vcs_current
- 'editv put vcs.0'
- 'editv get vcs_next_key vcs_prev_key vcs_split_key'
- IF vcs_next_key = '' THEN
- vcs_next_key = 'Alt-N'
- IF vcs_prev_key = '' THEN
- vcs_prev_key = 'Alt-P'
- IF vcs_split_key = '' THEN
- vcs_split_key = 'F9'
- * Define key to find the next deletion or insertion.
- 'define' vcs_next_key '"macro vcs !next"'
- * Define key to find the previous deletion or insertion.
- 'define' vcs_prev_key '"macro vcs !prev"'
- * Define key to toggle between vertical and horizontal windows.
- 'define' vcs_split_key '"macro vcs !split"'
- vcs_current = 0
- 'editv put vcs_current'
- arg = '!next'
- END
- 'editv get vcs_current'
- IF arg = '!next' THEN
- vcs_current = min(vcs_current + 1, vcs.0 + 1)
- ELSE
- vcs_current = max(vcs_current - 1, 0)
- IF vcs_current < 1 | vcs_current > vcs.0 THEN
- DO
- 'emsg No more deletions or insertions'
- exit
- END
- 'editv put vcs_current'
- * Make sure two windows.
- 'extract /screen'
- DO i = 1
- IF word(screen.1, i) = '' THEN
- leave
- END
- IF i <> 4 | word(screen.1, 1) <> 'SIZE' THEN
- 'screen 2 v'
- * Locate the corresponding file positions in both files and mark the deletion
- * or insertion block. Start with left or top window.
- IF lscreen.3() <> 1 | lscreen.4() <> 1 THEN
- 'sos tabcmdf'
- 'editv get vcs_fileone vcs_filetwo vcs.'vcs_current
- * Locate the fileone position.
- 'kedit' vcs_fileone '(nodefext'
- IF rc <> 0 THEN
- exit
- 'locate .vcs1.'vcs_current
- IF rc > 1 THEN
- exit
- IF vcs.vcs_current = '1' THEN
- DO
- * Mark the deletion block.
- 'reset block'
- i = line.1()
- 'locate 1'
- 'mark line'
- 'locate .vcs2.'vcs_current
- IF rc > 1 THEN
- exit
- 'locate -1'
- 'mark line'
- IF line.1() = i THEN
- 'reset block'
- 'locate :'i
- END
- * Move to right or bottom window.
- 'sos tabcmdf'
- * Locate the filetwo position.
- 'kedit' vcs_filetwo '(nodefext'
- IF rc <> 0 THEN
- exit
- 'locate .vcs1.'vcs_current
- IF rc > 1 THEN
- exit
- IF vcs.vcs_current = '2' THEN
- DO
- * Mark the insertion block.
- 'reset block'
- i = line.1()
- 'locate 1'
- 'mark line'
- 'locate .vcs2.'vcs_current
- IF rc > 1 THEN
- exit
- 'locate -1'
- 'mark line'
- IF line.1() = i THEN
- 'reset block'
- 'locate :'i
- END
- 'sos current firstcol'